package P1线性结构.LeetCode双指针;

public class LC11 {
    public int maxArea(int[] height) {
        int left = 0;
        int right = height.length - 1;
        int maxArea = 0;
        while (left < right) {
            if (height[left] <= height[right]) {
                int low = height[left];
                int area = (right - left) * low;
                maxArea = Math.max(maxArea,area);
                while (left < right && height[left] <= low) {
                    left++;
                }
            } else {
                int low = height[right];
                int area = (right - left) * low;
                maxArea = Math.max(maxArea,area);
                while (left < right && height[right] <= low) {
                    right--;
                }
            }
        }
        return maxArea;
    }
}